<template>
  <div class="login-panel">
    <h1>后台管理系统</h1>
    <el-tabs type="border-card" stretch>
      <el-tab-pane name="nameLogin">
        <template #label>
          <span class="custom-tabs-label">
            <el-icon style="margin-right: 8px">
              <User />
            </el-icon>
            <span>账号登录</span>
          </span>
        </template>
        <login-account ref="accountRef" />
      </el-tab-pane>
      <el-tab-pane name="phoneLogin">
        <template #label>
          <span class="custom-tabs-label">
            <el-icon style="margin-right: 8px">
              <Iphone />
            </el-icon>
            <span>手机登录</span>
          </span>
        </template>
        <login-phone />
      </el-tab-pane>
    </el-tabs>
    <div class="login-control f jc-sb">
      <el-checkbox v-model="isKeepPassword">记住密码</el-checkbox>
      <el-link type="primary">忘记密码</el-link>
    </div>
    <el-button
      type="primary"
      style="width: 100%; margin-top: 10px"
      @click="handleLogin"
      >登录</el-button
    >
  </div>
</template>

<script lang="ts">
import LoginAccount from './login-account.vue'; //为了拿到LoginAccount类型
export default defineComponent({
  name: 'LoginPanel',
  setUp() {
    const activeName = ref('nameLogin');
    const accountRef = ref<InstanceType<typeof LoginAccount>>(); // 获取组件类型的实例类型
    const isKeepPassword = ref(false);
    const handleLogin = () => {
      if (activeName.value === 'nameLogin') {
        accountRef.value?.loginAction();
      }
    };
    return {
      activeName,
      isKeepPassword,
      handleLogin
    };
  }
});
</script>
<style scoped lang="scss">
.login-panel {
  width: 320px;

  > h1 {
    text-align: center;
  }
}
</style>
